<%@page import="model.SubCategoryModel"%>
<%@page import="entity.Category"%>
<%@page import="model.CategoryModel"%>
<%@page import="model.TagModel"%>
<%@page import="model.NewsModel"%>
<%@page import="entity.News"%>
<%@page import="entity.Tag"%>
<%@page import="java.util.List"%>
<%@page import="entity.SubCategory"%>
<%@page import="util.ResourceHelper"%>

<%
	TagModel tagModel = new TagModel();
	CategoryModel cateModel = new CategoryModel();
	List<News> list = (List<News>) request.getAttribute("list");
	String key =null;
	if(request.getAttribute("key")!=null){
		key	= request.getAttribute("key").toString();
	}	 
	request.setCharacterEncoding("UTF-8");
	String cate = "index";
	String title = ResourceHelper.getByAlias("tim-kiem") + " : " + key + " - " + ResourceHelper.getByAlias("luu-tru-tin");
	String description = ResourceHelper.getByAlias("description");
%>	
<link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.8.16.custom.css" />	
<script type="text/javascript" src="/js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" >
$(function() {
	var dates = $( "#from, #to" ).datepicker({
		yearRange: "-30:+0",
		maxDate: "+0",
		defaultDate: "+1w",
		changeMonth: true,
		changeYear:true,
		numberOfMonths: 1,
		onSelect: function( selectedDate ) {
			var option = this.id == "from" ? "minDate" : "maxDate",
				instance = $( this ).data( "datepicker" ),
				date = $.datepicker.parseDate(
					instance.settings.dateFormat ||
					$.datepicker._defaults.dateFormat,
					selectedDate, instance.settings );
			dates.not( this ).datepicker( "option", option, date );
		}
	});
	$( "#from" ).datepicker( "option", "dateFormat", "dd-mm-yy" );
	$( "#to" ).datepicker( "option", "dateFormat", "dd-mm-yy" );
});
</script>
<jsp:include page="/layout/header.jsp">		
	<jsp:param name="title" value="<%=title %>"/>
	<jsp:param name="cate" value="<%=cate %>"/>
	<jsp:param name="keywords" value="<%=description %>"/>
	<jsp:param name="description" value="<%=description %>"/>
</jsp:include>
        <div id="content">
        	<div id="leftsidecontent">
            	<div class="box-wrap">
                	<div class="box-item" itemscope itemtype="http://schema.org/ItemList">                	                            
                            <div class="box-item_inner search-result" style="min-height: 898px;">
                            <form class="search-option" action="/tim-kiem" method="get">
                            	<label for="yourSearch"><%=ResourceHelper.getByAlias("nhap-tu-khoa") %></label>
                            	<input id="key" name="key" type="text" title="key" value="<%=(key==null)?"":key%>"/>
                            	<button type="submit"><%=ResourceHelper.getByAlias("tim-kiem") %></button>
                            	<div class="advanced-search">
                                	<div>
                                    	<span><%=ResourceHelper.getByAlias("chuyen-muc") %></span>
                                        <select id="cate" name="cate" title="cate" >
                                        	<option value="none"><%=ResourceHelper.getByAlias("tat-ca") %></option>
                                        <%                                        	
                                        	for(int i=0;i<cateModel.all().size(); i++)
                                        	{
                                        		Category item = cateModel.all().get(i);
                                        %>                                        	
                                            <option value="<%=item.getAlias()%>"><%=item.getTitle() %></option>                                           
                                         <%
                                        	}
                                         %>
                                        </select>
                                    </div>
                            		<div>
                            			<label for="from"><%=ResourceHelper.getByAlias("tu") %></label>
                            			<input id="from" name="from" type="text" />
                            			<label for="to"><%=ResourceHelper.getByAlias("den") %></label>
                            			<input id="to" name="to" type="text" />
                            			<div class="clearbreak"></div>
                            		</div>                           		
                            		<!-- <div>
                            			<label for="headline">Headline</label>
                            			<input id="headline" name="headline" type="text" />
                            			<div class="clearbreak"></div>
                            		</div>
                            		<div>
                            			<label for="author">Author</label>
                            			<input id="author" name="author" type="text" />
                            			<div class="clearbreak"></div>
                            		</div>   -->                                  
                            	</div>
                            </form>
                            <form class="option-display">
                            	<span><%=ResourceHelper.getByAlias("sap-xep-theo") %> : </span>
                                <select>
                                    <option><%=ResourceHelper.getByAlias("ngay-giam-dan") %></option>
                                    <option><%=ResourceHelper.getByAlias("ngay-tang-dan") %></option>
                                </select>
                                <span><%=ResourceHelper.getByAlias("so-luong-ket-qua") %> : </span>
                                <select>
                                    <option>100 <%=ResourceHelper.getByAlias("ket-qua") %></option>
                                    <option>200 <%=ResourceHelper.getByAlias("ket-qua") %></option>                                  
                                    <option><%=ResourceHelper.getByAlias("tat-ca") %></option>
                                </select>
                                <span><%=ResourceHelper.getByAlias("moi-trang") %> : </span>
                                <select>
                                    <option>10 <%=ResourceHelper.getByAlias("ket-qua") %></option>
                                    <option>20 <%=ResourceHelper.getByAlias("ket-qua") %></option>
                                    <option>30 <%=ResourceHelper.getByAlias("ket-qua") %></option>
                                    <option>40 <%=ResourceHelper.getByAlias("ket-qua") %></option>
                                    <option>50 <%=ResourceHelper.getByAlias("ket-qua") %></option>                                
                                </select>
                                <button type="submit"><%=ResourceHelper.getByAlias("hien-thi") %></button>
                            </form>
                            <div style="border-bottom: 1px solid #E5E5E5; margin-bottom: 5px; padding-bottom: 5px;">
                            	<%=request.getAttribute("infor") %>
                            </div>
                            <meta itemprop="itemListOrder" content="Descending" /> 
                            <%
                            	if(list!=null&&list.size()>0){
                            		
                            	
                            %>
                            <ul class="news-item-listing list-news">
                            	<%
	                            	for (News n : list) {	
	                        			%>
	                        			<li itemprop="itemListElement" itemscope itemtype="http://schema.org/Article">
		                            		<h3 itemprop="name"><a itemprop="url" href="/<%=n.getAlias()%>.html"><%=n.getTitle() %></a>&nbsp;<time datetime="2011-12-18">(<%=n.getDoc().toGMTString() %>)</time></h3>		                            			                         
			                            		<p class="description" itemprop="description">
                           								<%= n.getDescription().replaceAll("<img[^>]+>", "")%> 								
												</p>
		                            	</li>   
	                        			<%
	                        		}
                            	%>
                         	       <%
                            	}else if(request.getAttribute("msg")!=null){
                            		%>
                            			<p style="color: red"><%=request.getAttribute("msg")%></p>
                            		<%
                            	}
                            %>                          
                            </ul>    
                            <ul class="pagination">
                                <li class="current"><span>1</span></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">5</a></li>
                                <li><a href="#">6</a></li>
                                <li><a href="#">7</a></li>
                                <li><a href="#">8</a></li>
                                <li><a href="#">9</a></li>
                                <li><a href="#">10</a></li>
                                <li><a href="#">next</a></li>
                            </ul>
                        </div>                        
                    </div>
                </div>
            </div>
            <div id="rightsidecontent">
            	<div class="box-wrap">                	           
                     <jsp:include page="/element/latest_news.jsp">	
                       	<jsp:param name="cate" value="<%=cate%>"/>	
					 </jsp:include>
                      <jsp:include page="/element/another_news.jsp">
                       	<jsp:param name="cate" value="<%=cate%>"/>		
					 </jsp:include>
                    
                    <div class="clearbreak"></div>               
                    <div class="clearbreak"></div>
                </div>
            </div>
            <div class="clearbreak"></div>
        </div>
<jsp:include page="/layout/footer.jsp">	
	<jsp:param name="cate" value="<%=cate%>"/>	
</jsp:include>
	